#import "FlutterInvest3desPlugin.h"
#import "NSString+encryptDES.h"
@implementation FlutterInvest3desPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  FlutterMethodChannel* channel = [FlutterMethodChannel
      methodChannelWithName:@"flutter_invest_3des"
            binaryMessenger:[registrar messenger]];
  FlutterInvest3desPlugin* instance = [[FlutterInvest3desPlugin alloc] init];
  [registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  if ([@"getPlatformVersion" isEqualToString:call.method]) {
    result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  } else if([@"encrypt" isEqualToString:call.method]) {
    NSDictionary* argsMap=call.arguments;
    NSString * data=argsMap[@"data"];
    NSString * key=argsMap[@"key"];
    
    NSString *encryptStr = [NSString encrypt3DES:data key:key];
      
    if (encryptStr) {
        result(encryptStr);
    } else
    {
        result([FlutterError errorWithCode:@"UNAVAILABLE"
        message:@"encrypt3DES unavailable"
        details:nil]);
    }
  }else {
      
    result(FlutterMethodNotImplemented);
  }
}

@end
